<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
import Edit from "./../edit/index";
export default {
  mixins: [
    Vue.prototype.$vFN.Mixins.Base,
    Vue.prototype.$vFN.Mixins.Page,
    Vue.prototype.$vFN.Mixins.Table,
  ],
  data() {
    return {
      appWindow: window,
      // 页面接口地址
      apiUrl: {
        list: "plugin/distribution/backend/levels/index?pageNum=1&pageSize=20",
        // delete: "plugin/dealer-bonus/admin/level/destroyLevel",
      },
      // 表格查询数据
      mixinTable_tableSearchData: {},
    
      levelCommission: null,
      // 表格数据删除展示结构
      tableDeleteConfig: {
        columns: [
          {
            label: "等级名称",
            prop: "name",
          },
        ],
      },
      // 表格数据类型
      mixinTable_tableDataType: "tree",
    };
  },
  methods: {
    // 启用/禁用
    async state(_id,) {
      let res = await this.$vFN.Http.post({
        url: "plugin/distribution/backend/levels/toggleDisable",
        data: {
          id: _id,
          // upgrade_type: _id,
        }
      }, window)
      if(res.code == 200) {
        this.$vFN.Tools.messageSuccess("操作成功");
        this.mixinTable_refreshData();
      }
    },
    async setCommission() {
      let res = await this.$vFN.Http.post({
        url: "plugin/distribution/backend/settings/base/get",
      }, window);
      this.levelCommission = res.data.level;
    },
    // 打开添加/修改
    async editBoxOpen(params_) {
      Edit.init({
        mixinEdit_parent: this,
        mixinEdit_editType: params_.type,
        id: params_.id,
        levelCommission: this.levelCommission,
      });
    },
    // 初始化
    async init() {
      this.setCommission()
      this.mixinTable_refreshData();
    },
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>